package com.example.configclient;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Springboot 2.0之后Config客户端自动刷新时没有/bus/refresh端点
 * http://localhost:8881/actuator/bus-refresh
 * 必须 POST请求
 * 参考博客：https://www.cnblogs.com/lzj123/p/9724499.html
 * @author guoc
 * @date 2020/7/9 16:34
 */

@SpringBootApplication
@RestController
@RefreshScope //在客户端使用配置的类加上@RefreshScope注解
public class ConfigClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigClientApplication.class, args);
    }

    @Value("${foo}")
    String foo;
    @RequestMapping(value = "/hi")
    public String hi(){
        return foo;
    }
}
